﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace StorageBox
{
    /// <summary>
    /// 选项页的事件
    /// </summary>
    public partial class MainWindow : Window
    {
        //考虑选择页的显示是否需要格式化,是否放到Reader中去显示
        #region 批量选择开始菜单
        /// <summary>
        /// 选项点击
        /// </summary>
        private void StateMenuApplu_CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            var index = (sender as CheckBox).Uid;
            var data = ReaderManager.GetRender<MainTabControlReader>().GetCurrData<AddRangApplyData>();
            data.SetChecked(Convert.ToInt32(index), Convert.ToBoolean((sender as CheckBox).IsChecked));
        }
        /// <summary>
        /// 确认添加
        /// </summary>
        private void AddRandApply_ConfirmBut_Click(object sender, RoutedEventArgs e)
        {
            //获取确认集合
            var data = ReaderManager.GetRender<MainTabControlReader>().GetCurrData<AddRangApplyData>();
            var dataList = data.GetCheckedData();
            //创建元素
            foreach (var item in dataList)
            {
                var elementData = new ApplyData()
                {
                    Langth = new Size() { Width = 1, Height = 1 },
                    Name = item.Name,
                };
                ReaderManager.GetRender<DesktopReader>().ShowItem(elementData);
            }


            //关闭视图
            var reader = ReaderManager.GetRender<MainTabControlReader>();
            reader.SetMainTabControlState = MainTabControlState.None;
        }
        #endregion


        /// <summary>
        /// 返回按键
        /// </summary>
        private void MainTabControl_ReturnBut_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var reader = ReaderManager.GetRender<MainTabControlReader>();
            reader.SetMainTabControlState = MainTabControlState.None;
        }
    }
}
